export default {
  namespaced: true,
  state: () => ({
    article_id: null, //用户文章id
    article: {}, //文章信息
    top_article: [], //置顶文章
    articleList: [], //文章列表
    sort: 1, //选项卡
    page: 1, //页数
    pagesize: 20, //页数大小
    group_id: "all",
    circleGroup: false, //开启分组 true 表示是某一项游戏的圈子，false 表示的是所有游戏的圈子
  }),
  getters: {
    circleGroup(state) {
      return state.circleGroup;
    },
    article_id(state) {
      return state.article_id;
    },
    articleList(state) {
      return state.articleList;
    },
    sort(state) {
      return state.sort;
    },
    top_article(state) {
      return state.top_article;
    },
    page(state) {
      return state.page;
    },
    pagesize(state) {
      return state.pagesize;
    },
    group_id(state) {
      return state.group_id;
    },
  },
  mutations: {
    changeArticle_id(state, params) {
      state.article_id = params;
    },
    changeArticleList(state, params) {
      state.articleList = params;
    },
    changeTopArticle(state, params) {
      state.top_article = params;
    },
    changeSort(state, params) {
      state.sort = params;
    },
    changeGroup_id(state, params) {
      state.group_id = params;
    },
    changeCircleGroup(state, params) {
      state.circleGroup = params;
    },
  },
  actions: {
    getArticleListAction({ commit, state }) {
      const res = this.$axios.get(
        `https://api.vgn.cn/apiv2/group/article/index?page=${String(
          state.page
        )}&sort=${String(state.sort)}&page_size=${String(state.pagesize)}`
      );
      commit("changeArticleList", res.data.article_list);
      commit("changeTopArticle", res.data.top_article);
    },
  },
  modules: {},
};
